// pages/home_new/home.js
const app = getApp();
var router = require("../../router.js");
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    indicatorDots: true, //是否添加轮播小圆点
    autoplay: true, //是否自动播放
    interval: 5000, //轮播间隔时间
    duration: 1000, //动画过渡时间
    imgUrls: [ //banner图片数据          
    ],
    shouye_data:'',
    jieshao_data:'',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    go_buy_safe(event) {
      var index = event.currentTarget.dataset.id;
      app.navTo('../buy/buy?id=' + this.data.safe[index]['id'])
    },
    go_index_detail(e){
      var id = e.currentTarget.dataset.chanelid;
      wx.navigateTo({
        url: '/pages/home_new/home_detail?id=' + id + '&types='+1,
      })
    }
  },
  attached() {
    console.log("加载数据")
    var that = this;
    app.request({
      url: router.index.indexss,
      method: "POST",
      data: {},
      success: function (data) {
        if (data.status == true) {
          that.setData({
            safe: data.safe,
            imgUrls: data.banner,
          });
        }
      }
    })
    app.request({
      url: router.index.column,
      method: "POST",
      data: {},
      success: function (res) {
        if (res) {
          that.setData({
            column: res,
          });
        }
      }
    })
    app.request({
      url: router.index.event_show,
      method: "POST",
      data: { type_leixing: 1 },
      success: function (res) {
        if (res) {
          that.setData({
            shouye_data: res,
          });
        }
      }
    })
    app.request({
      url: router.index.jieshao,
      method: "POST",
      data: { types: 1 },
      success: function (res) {
        if (res) {
          that.setData({
            jieshao_data: res.res,
          });
        }
      }
    })
  },
  detached(){
    console.log("首页页面被移除")
  }
})
